﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TurboTemplate
{
    public partial class NewTemplateDialog : Form
    {
        public string TemplateName
        {
            get
            {
                return tbTemplateName.Text;
            }
        }

        public NewTemplateDialog()
        {
            InitializeComponent();
        }

        public NewTemplateDialog(string templateName) : this()
        {
            tbTemplateName.Text = templateName;
        }

        private void NewTemplateDialog_Load(object sender, EventArgs e)
        {
            tbTemplateName.Focus();
            UpdateUI();
        }

        private void tbTemplateName_TextChanged(object sender, EventArgs e)
        {
            UpdateUI();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.Cancel;
            Close();
        }

        private void UpdateUI()
        {
            btnOK.Enabled = tbTemplateName.TextLength > 0;
        }
    }
}
